package com.jcl.recruit.elasticsearch.core.tools;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName Condition

 * @Author yyliu
 * @Date 2018/10/26 16:47
 * @Version 1.0
 **/
public class Condition {
    private List<Map<String, String>> sort = null;
    private Map<String, Object> aggs = null;
    private QueryBool query = new QueryBool();
    private Integer from;
    private Integer size = 10;

    public QueryBool getQuery() {
        return query;
    }

    public void setQuery(QueryBool queryBool) {
        this.query = queryBool;
    }

    public Integer getFrom() {
        return from;
    }

    public void setFrom(Integer from) {
        this.from = from * size;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public List<Map<String, String>> getSort() {
        return sort;
    }

    public void setSort(String key, String desc) {
        if (null == sort) {
            sort = new ArrayList<>();
        }
        Map<String, String> map = new HashMap<>();
        map.put(key, null == desc ? "desc" : desc);
        this.sort.add(map);
    }

    public Map<String, Object> getAggs() {
        return aggs;
    }

    public void setAggs(Map<String, Object> aggs) {
        this.aggs = aggs;
    }

}
